{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "edf6d881-c35e-46bc-bc8c-f255d483163a",
   "metadata": {},
   "source": [
    "# MS-DOS 命令行操作"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6471a6b7-ed35-4bbb-9d1c-0e74603d3ed9",
   "metadata": {},
   "source": [
    "1.改变盘符C:,D:......\n",
    "\n",
    "   D:<回车>\n",
    "   \n",
    "2.cd<回车>-检查当前的目录\n",
    "\n",
    "3.cd<sp>文件夹名字-跳转到该目录\n",
    "\n",
    "   D:\\>cd 文件名1\\文件名2-直接跳转到文件名2\n",
    "   \n",
    "4.md<sp>文件名-创建文件夹\n",
    "\n",
    "   rd<sp>文件名-删除文件夹\n",
    "   \n",
    "   D:\\>md D:\\文件名1\\文件名2-创建文件名2\n",
    "   \n",
    "5.echo<sp>”i love you”>1.txt-创建名为“1”的文档文件，里面内容为“i love you”\n",
    "\n",
    "6.dir-列出所有的文件\n",
    "\n",
    "*表示所有的组合\n",
    "\n",
    "dir *.*\n",
    "\n",
    "7.type<sp>文件名.拓展名\n",
    "\n",
    "8.copy<sp><源文件名><目标文件名>\n",
    "\n",
    "   copy 1.txt 2.txt\n",
    "   \n",
    "9.绝对路径\n",
    "\n",
    "   D:\\work\\fengjian\\1\n",
    "   \n",
    "   相对路径\n",
    "   \n",
    "   D:\\work>  fengjian\\1\n",
    "   \n",
    "10.del<sp>*.*-删除文件\n",
    "\n",
    "   move<sp>*.*-移动文件\n",
    "   \n",
    "11. .\\当前级 ..\\-返回上一级"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2fe5f2e1-78f2-4bf6-b14d-2077ba7d0010",
   "metadata": {},
   "source": [
    "# 常用git命令"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "798af356-d539-44c5-817d-96f6505143dc",
   "metadata": {},
   "source": [
    "提交思路： \n",
    "\n",
    "git status\n",
    "\n",
    "git add .-增加修改后文件\n",
    "\n",
    "git commit -m “”-提交文件\n",
    "\n",
    "git push"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cc9fb617-b4b2-4cdb-9674-7b56f02f8b57",
   "metadata": {},
   "source": [
    "# python命令"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46215908-2d87-4601-aad9-815b077df7f4",
   "metadata": {},
   "source": [
    "## 1 变量类型"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a66f5c48-a8d6-4e2e-8b1c-deb121e0d526",
   "metadata": {},
   "source": [
    "数字类型\n",
    "\n",
    "* int (整型)\n",
    "\n",
    "* float (浮点型)\n",
    "\n",
    "* complex (复数)\n",
    "\n",
    "文本序列类型\n",
    "\n",
    "* str (字符串)： 用单引号 \n",
    "\"' '\"、双引号 \n",
    "\"\" \"\" 或三引号 \n",
    "\"''' '''\" / \n",
    "\"\"\"\" \"\"\"\" 包裹的文本。如 \n",
    "\"\"hello\"\", \n",
    "\"'世界'\"。\n",
    "\n",
    "布尔类型\n",
    "\n",
    "* bool (布尔)： 只有两个值 \n",
    "\"True\" 和 \n",
    "\"False\"。常用于条件判断。注意首字母大写。\n",
    "\n",
    "序列类型\n",
    "\n",
    "* list (列表)： 有序、可变的元素集合，用方括号 \n",
    "\"[ ]\" 表示。如 \n",
    "\"[1, 'a', True]\"\n",
    "* tuple (元组)： 有序、不可变的元素集合，用圆括号 \n",
    "\"( )\" 表示。如 \n",
    "\"(1, 'a', True)\"\n",
    "* range： 表示一个不可变的数字序列，通常用于循环。如 \n",
    "\"range(5)\" -> \n",
    "\"(0, 1, 2, 3, 4)\"\n",
    "\n",
    "集合类型\n",
    "\n",
    "* set (集合)： 无序、不重复元素的集合，用花括号 \n",
    "\"{ }\" 或 \n",
    "\"set()\" 函数创建。如 \n",
    "\"{1, 2, 3}\"\n",
    "* frozenset (不可变集合)： 不可变的集合。\n",
    "\n",
    "映射类型\n",
    "\n",
    "* dict (字典)： 无序的 键值对 (key-value) 集合，用花括号 \n",
    "\"{ }\" 表示，键和值用冒号 \n",
    "\":\" 分隔。如 \n",
    "\"{'name': 'Alice', 'age': 25}\"\n",
    "\n",
    "二进制类型\n",
    "\n",
    "* bytes： 不可变的字节序列。\n",
    "* bytearray： 可变的字节序列。\n",
    "* memoryview： 用于访问其他二进制对象的内存，无需拷贝。\n",
    "\n",
    "查看变量类型的方法：\n",
    "\n",
    "使用 \n",
    "\"type()\" 函数。\n",
    "\n",
    "name = \"Python\"\n",
    "print(type(name)) # 输出：<class 'str'>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cbce1986-6394-4a3d-a4b0-73fdeabe16a8",
   "metadata": {},
   "source": [
    "## 2 变量命名规则"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7c1a7a2a-b758-44eb-8735-46c8a1718b5c",
   "metadata": {},
   "source": [
    "为变量取名时需要遵循以下规则和约定：\n",
    "\n",
    "硬性规则 (必须遵守，否则会报错)\n",
    "\n",
    "1. 由字母、数字和下划线 \n",
    "\"_\" 组成。\n",
    "2. 不能以数字开头。 (\n",
    "\"2nd_place\" 是错的，\n",
    "\"_2nd_place\" 是对的)。\n",
    "3. 不能是 Python 的关键字 (保留字)。如 \n",
    "\"if\", \n",
    "\"for\", \n",
    "\"while\", \n",
    "\"class\", \n",
    "\"def\" 等。\n",
    "   * 查看所有关键字：\n",
    "\"import keyword; print(keyword.kwlist)\"\n",
    "4. 区分大小写。\n",
    "\"age\", \n",
    "\"Age\", \n",
    "\"AGE\" 是三个不同的变量。\n",
    "\n",
    "惯例/规范 (约定俗成，建议遵守)\n",
    "\n",
    "1. 见名知意： 变量名应具有描述性，让人一看就知道它代表什么。例如，用 \n",
    "\"student_name\" 而不是 \n",
    "\"sn\"。\n",
    "2. 蛇形命名法： Python 推荐使用小写字母和下划线来组合命名，即 \n",
    "\"snake_case\"。这是 PEP 8 官方风格指南的推荐。\n",
    "   * 例如：\n",
    "\"user_id\", \n",
    "\"first_name\", \n",
    "\"total_count\"\n",
    "3. 避免使用拼音和中文： 虽然技术上支持中文变量名，但强烈不推荐。\n",
    "4. 单下划线开头 \n",
    "\"_variable\"： 通常表示“内部使用”的变量或方法，是一种弱提示。\n",
    "5. 双下划线开头 \n",
    "\"__variable\"： 用于类的命名修饰 (Name Mangling)，会让解释器重写属性名，以避免与子类中的命名冲突。\n",
    "6. 全大写变量名 \n",
    "\"CONSTANT_VAR\"： 通常用于表示常量，提示这个值在程序中不应被修改。\n",
    "\n",
    "好的例子： \n",
    "\"pi\", \n",
    "\"max_connections\", \n",
    "\"is_valid\", \n",
    "\"user_list\"\n",
    "\n",
    "坏的例子： \n",
    "\"a\", \n",
    "\"b1\", \n",
    "\"2var\", \n",
    "\"my-variable\" (含连字符), \n",
    "\"class\" (关键字)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8eec5de3-090a-47d4-b289-e2c09e063817",
   "metadata": {},
   "source": [
    "## 3 运算符"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a54ff735-39a4-46ee-91ca-8d4807ae1321",
   "metadata": {},
   "source": [
    "运算符是用于对变量和值执行操作的符号。\n",
    "\n",
    "算术运算符\n",
    "\n",
    "用于基本的数学运算。\n",
    "\n",
    "* \n",
    "\"+\"： 加法\n",
    "* \n",
    "\"-\"： 减法\n",
    "* \n",
    "\"*\"： 乘法\n",
    "* \n",
    "\"/\"： 除法 (总是返回浮点数，如 \n",
    "\"10 / 2\" -> \n",
    "\"5.0\")\n",
    "* \n",
    "\"//\"： 取整除法/地板除 (向下取整，如 \n",
    "\"10 // 3\" -> \n",
    "\"3\")\n",
    "* \n",
    "\"%\"： 取模/取余 (返回除法的余数，如 \n",
    "\"10 % 3\" -> \n",
    "\"1\")\n",
    "* \n",
    "\"**\"： 幂运算/乘方 (如 \n",
    "\"2 ** 3\" -> \n",
    "\"8\")\n",
    "\n",
    "比较运算符\n",
    "\n",
    "用于比较两个值，返回布尔值 \n",
    "\"True\" 或 \n",
    "\"False\"。\n",
    "\n",
    "* \n",
    "\"==\"： 等于\n",
    "* \n",
    "\"!=\"： 不等于\n",
    "* \n",
    "\">\"： 大于\n",
    "* \n",
    "\"<\"： 小于\n",
    "* \n",
    "\">=\"： 大于等于\n",
    "* \n",
    "\"<=\"： 小于等于\n",
    "\n",
    "赋值运算符\n",
    "\n",
    "用于给变量赋值。\n",
    "\n",
    "* \n",
    "\"=\"： 基本赋值 (\n",
    "\"x = 10\")\n",
    "* \n",
    "\"+=\"： 加后赋值 (\n",
    "\"x += 5\" 等价于 \n",
    "\"x = x + 5\")\n",
    "* \n",
    "\"-=\"： 减后赋值\n",
    "* \n",
    "\"*=\"： 乘后赋值\n",
    "* \n",
    "\"/=\"： 除后赋值\n",
    "* \n",
    "\"//=\"： 取整除后赋值\n",
    "* \n",
    "\"%=\"： 取模后赋值\n",
    "* \n",
    "\"**=\"： 幂运算后赋值\n",
    "\n",
    "逻辑运算符\n",
    "\n",
    "用于组合多个条件。\n",
    "\n",
    "* \n",
    "\"and\"： 逻辑与 (两边都为 \n",
    "\"True\"，结果才为 \n",
    "\"True\")\n",
    "* \n",
    "\"or\"： 逻辑或 (只要一边为 \n",
    "\"True\"，结果就为 \n",
    "\"True\")\n",
    "* \n",
    "\"not\"： 逻辑非 (取反，\n",
    "\"not True\" 为 \n",
    "\"False\")\n",
    "\n",
    "身份运算符\n",
    "\n",
    "用于比较两个对象的内存地址是否相同（即是否是同一个对象）。\n",
    "\n",
    "* \n",
    "\"is\"： 如果两个变量是同一个对象则返回 \n",
    "\"True\"\n",
    "* \n",
    "\"is not\"： 如果两个变量不是同一个对象则返回 \n",
    "\"True\"\n",
    "\n",
    "a = [1, 2]\n",
    "b = a # b 和 a 指向同一个列表对象\n",
    "c = [1, 2] # c 是新建的一个列表对象，内容相同但内存地址不同\n",
    "\n",
    "print(a is b) # True\n",
    "print(a is c) # False (虽然值相等，但不是同一个对象)\n",
    "\n",
    "成员运算符\n",
    "\n",
    "用于测试一个值是否在某个序列（如字符串、列表、元组）中。\n",
    "\n",
    "* \n",
    "\"in\"： 如果在序列中找到值则返回 \n",
    "\"True\"\n",
    "* \n",
    "\"not in\"： 如果在序列中没有找到值则返回 \n",
    "\"True\"\n",
    "\n",
    "fruits = ['apple', 'banana']\n",
    "print('apple' in fruits) # True\n",
    "print('orange' not in fruits) # True\n",
    "\n",
    "位运算符\n",
    "\n",
    "直接对整数在内存中的二进制位进行操作（较少使用）。\n",
    "\n",
    "* \n",
    "\"&\"： 按位与\n",
    "* \n",
    "\"|\"： 按位或\n",
    "* \n",
    "\"^\"： 按位异或\n",
    "* \n",
    "\"~\"： 按位取反\n",
    "* \n",
    "\"<<\"： 左移\n",
    "* \n",
    "\">>\"： 右移"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "28314141-2266-486e-8acc-2ca766462892",
   "metadata": {},
   "source": [
    "# 摄氏度和华氏度转换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d3246e16-0cb9-42fe-8342-1b49a0fd4c8c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请选择转换模式:\n",
      "1.摄氏度→华氏度\n",
      "2.华氏度→摄氏度\n",
      " 1\n",
      "输入温度 30\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "30℃ = 86.0℉\n"
     ]
    }
   ],
   "source": [
    "def c_to_f(c):\n",
    "    return(1.8*c)+32\n",
    "def f_to_c(f):\n",
    "    return(f-32)/1.8\n",
    "mode=input(\"请选择转换模式:\\n1.摄氏度→华氏度\\n2.华氏度→摄氏度\\n\")\n",
    "t=eval(input(\"输入温度\"))\n",
    "if mode == \"1\":\n",
    "    print(f\"{t}℃ = {c_to_f(t):.1f}℉\")\n",
    "elif mode == \"2\":\n",
    "    print(f\"{t}℉ = {f_to_c(t):.1f}℃\")\n",
    "else:\n",
    "    print(\"无效\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "60a31c2b-2c0b-472b-86b7-acf3476cce44",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
